<?php
require_once('../includes/SmartyManager.class.php');
require_once('../includes/DB.class.php');
require_once('../includes/Verifier.class.php');
require_once('../includes/Filter.class.php');
require_once('../includes/ChukuFileAccountant.class.php');
require_once('../includes/SimpleTableExporter.class.php');

ini_set("max_execution_time",0);
ini_set( "memory_limit" , "128M");

try{
$smarty = SmartyManager::getSmarty();
$chuku = new ChukuFileAccountant($_GET['id']);
$chuku->execute();

$query = 'select filename from little_chuku_file where id = '.$_GET['id'];
DB::query($query);
$row = DB::getResult()->fetch_assoc();
$chukuFilename = $row['filename'];
$filename = iconv('utf-8', 'gbk', '证书出库明细'.'_('.pathinfo($chukuFilename, PATHINFO_FILENAME).')_'.date('YmdHis').'.xls');
$exp = new SimpleTableExporter($filename);
$exp->insertCustomData(array(
					$chuku->getCertificationNumber(),
				 	$chuku->getCertificationCodification(),
				 	$chuku->getSequenceNumber(),
				 	$chuku->getManufactory(),
				 	$chuku->getAuthenticationMark(),
				 	$chuku->getSteelNumber(),
				 	$chuku->getSize1(),
				 	$chuku->getSize2(),
				 	$chuku->getSize3(),
					$chuku->getCount(),
					$chuku->getUnitWeight(),
					$chuku->getOrderNumber(),
					$chuku->getOrderSubitemNumber(),
					$chuku->getUnitPrice(),
					$chuku->getMaterialNumber(),
					$chuku->getConsignmentBatch(),
					$chuku->getSampleBatch(),
					$chuku->getFacheNumber(),
					$chuku->getPurchaseNumber(),
					$chuku->getShipmentDate(),
					$chuku->getMonth(),
					$chuku->getVehicleNumber(),
					$chuku->getConsignee(),
					$chuku->getHandler(),
					$chuku->getRemark()), 
	array('产品质量证明书号','产品质量证明书编号','批次','生产厂家','船级','材质','厚 ','宽','长','数量','单重',
				'订单号','订单子项号','受订单价','物料号','发货批次','批号','发车证书号','购单号','发货时间','合同月份','车号',
				'销售产家','经手人','备注'), 
		'sheet1');
$exp->export();
}catch(Exception $e){
	$smarty = SmartyManager::getSmarty();
	$smarty->assign('errMsg', $e);
	$smarty->assign('errTitle', '查询数据库时出现错误');
	$smarty->display('error.html');
	die();
}

?>